#pragma once

#include "Types.h"

#include <MyControls/EnumProperty.h>
#include <MyControls/CompositeProperty.h>

enum DisplayType 
{
	MaskOnly,	///< only mask in black-white pallete is shown
	ObjectOnly,
	BackgroundOnly,
	MattedObject, ///< background is ignored
	Composition ///< composition of object and background (shall not be choosen if there is no background)
};

struct DisplayStyle
{
	DisplayType Type;
	// not for ObjectOnly and BackroundOnly
	bool SmoothMask; /// true=soft, false=crisp
	bool InverseMask;
	/// Only for MattedObject style.
	/// In the same time it's background color if no background footage is loaded;
	/// alpha component contains opacity of matte: 0 - transparent, 255 - opaque
	ByteColor	MatteColor;
public:
	bool MaskStyleDisabled() const
		{ return Type == ObjectOnly || Type == BackgroundOnly; }
	My::Percent<> GetMatteOpacity() const
		{ return My::Percent<>(MatteColor.a / 255.f); }
	void SetMatteOpacity(My::Percent<> a)
		{ MatteColor.a = static_cast<unsigned char>(a * 255.f + 0.5f); }
	bool MatteStyleDisabled() const
		{ return Type != MattedObject; }
public:
	void WriteSettings();
	void ReadSettings();
};

/// comparison of equality of visual effect
bool operator == (const DisplayStyle & lhs, const DisplayStyle & rhs);

inline bool operator != (const DisplayStyle & lhs, const DisplayStyle & rhs)
	{ return !(lhs == rhs); }

template <>
class My::Property<DisplayStyle> : public My::StructProperty<DisplayStyle> {
public:
	Property();
public:
	virtual void Init();
};
